import { AnyAction, Reducer } from "redux";
import { EffectsCommandMap } from "dva";

export interface StateType {
    status?: 'ok' | 'error';
    type?: string;
    currentAuthority?: 'user' | 'guest' | 'admin';
}

export type Effect = (
    action: AnyAction,
    effects: EffectsCommandMap & { select: <T>(func: (state: StateType) => T) => T }
) => void;

export interface ModelType {
    namespace: string;
    state: StateType;
    effects: {
        login: Effect;
        getCaptcha: Effect;
    };
    reducers: {
        changeLoginStatus: Reducer<StateType>;
    };
}

const Model: ModelType = {
  namespace: 'userAndLogin',

  state: {
    status: undefined,
  },

  effects: {
    //构造器
    *login({ payload }, { call, put }) {

    }
  }

}

export default Model;